﻿using System;
using System.Diagnostics.Contracts;
using System.IO;

namespace Windows.Toolkit
{
    public class FileDialogResult
    {
        #region Invariant

        [ContractInvariantMethod]
        private void FileDialogResultInvariantMethod()
        {
            Contract.Invariant(!string.IsNullOrEmpty(_fileName));
            Contract.Invariant(_stream != null);
        }

        #endregion

        #region Properties

        private string _fileName;
        public string FileName
        {
            get
            {
                Contract.Ensures(!string.IsNullOrEmpty(Contract.Result<string>()));
                return _fileName;
            }
        }

        private Stream _stream;
        public Stream Stream
        {
            get
            {
                Contract.Ensures(Contract.Result<Stream>() != null);
                return _stream;
            }
        }

        #endregion

        #region Constructors

        public FileDialogResult(string fileName, Stream stream)
        {
            Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(fileName), "FileName cannot be null or empty.");
            Contract.Requires<ArgumentNullException>(stream != null, "Stream cannot be null.");

            _fileName = fileName;
            _stream = stream;
        }

        #endregion
    }
}
